
<div class="main_bd">

    <div class="panel panel_overview">
        <div class="panel__hd">
            <h3 class="panel__title">订单列表</h3></div>
        <div class="panel__bd">

            <!--<div class="filter-box">-->
            <!--<a href="" class="btn btn_primary">新建群发</a>-->
            <!--</div>-->
            <div class="fieldset">
                <h3 class="title">订单信息</h3>
                <div class="box">
                    <table class="info-list">
                        <tr>
                            <td class="label">订单号</td>
                            <td>{$model.trade_no}</td>
                            <td class="label">订单类型</td>
                            <td>{$model.module.name}订单</td>
                            <td class="label">创建时间</td>
                            <td>{$model.create_time}</td>
                        </tr>
                        <tr>
                            <td class="label">订单总额</td>
                            <td class="red">￥{$model.amount}</td>
                            <td class="label">订单状态</td>
                            <td id="status">
                                {switch $model.status}
                                    {case 0}待付款{/case}
                                    {case 1}待发货{/case}
                                    {case 2}待收货{/case}
                                    {case 4}待评价{/case}
                                    {case 5}已评价{/case}
                                    {case 6}退款/售后{/case}
                                    {case -1}订单失败{/case}
                                    {default /}状态异常
                                {/switch}
                            </td>
                            <td class="label">第三方支付订单号</td>
                            <td>{$model.unifiedOrder.out_trade_no}</td>
                        </tr>
                        <tr>
                            <td class="label">收货人</td>
                            <td>{$model.buyer_name}</td>
                            <td class="label">联系方式</td>
                            <td>{$model.buyer_phone}</td>
                            <td class="label">详细地址</td>
                            <td>{$model.buyer_address} <em>[邮编]</em> {$model.buyer_postcode}</td>

                        </tr>
                    </table>
                </div>
            </div>
            <div class="fieldset">
                <h3 class="title">支付情况</h3>
                <div class="box">
                    <table class="info-list">
                        <tr>
                            <td width="100px" class="label">支付渠道</td>
                            <td><span class=" padding10-c">{$pay.channel}</span></td>
                            <td width="100px" class="label">支付平台预下单号</td>
                            <td><span class=" padding10-c">{$pay.out_trade_no}</span></td>
                        </tr>
                        <tr>
                            <td width="100px" class="label">支付时间</td>
                            <td><span class=" padding10-c">{$model.update_time}</span></td>
                            <td width="100px" class="label">支付结果</td>
                            <td><span class=" padding10-c">
                                 {switch $pay.status}
                                    {case 0}支付失败{/case}
                                    {case 1}支付成功{/case}
                                    {default /}状态异常
                                {/switch}
                            </span></td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="fieldset">
                <h3 class="title">购买详情</h3>
                <div class="box">
                    <table class="info-list">
                        <tr>
                            <th width="100px">商品id</th>
                            <th width="300px">商品名称</th>
                            <th  width="80px">缩略图</th>
                            <th>规格</th>
                            <th>购买数量</th>
                            <th>单价</th>
                        </tr>
                        {volist name="$model.purchaser" id="purchaser" }
                        <tr>
                            <td>{$purchaser.mall_id}</td>
                            <td>{$purchaser.title}</td>
                            <td><img width="60px" src="{$purchaser.thumb}" /></td>
                            <td>
                                {volist name="purchaser.mallSpec" id="spec" }
                                <div class="info-line"><span class="em">{$spec.title}</span> : <span>{$spec.val}</span></div>
                                {/volist}
                            </td>
                            <td>{$purchaser.number}</td>
                            <td>{$purchaser.price}</td>

                        </tr>
                        {/volist}
                    </table>
                </div>
            </div>

            <div class="fieldset">
                <h3 class="title">物流相关</h3>
                <div class="box">
                    <table class="info-list">
                        {if $model.send_status=='等待支付'}
                        <tr>
                            <td>该订单暂未支付,无需发货</td>
                        </tr>
                        {elseif $model.send_status=='待发货'}
                        <tr>
                            <td colspan="6" style="color: #953b39">用户已经付款，请尽快发货</td>

                        </tr>
                        <tr>
                            <td class="label">快递/物流名称</td>
                            <td>
                                <select name="send_type_id" id="send_type_id">
                                    {volist name='express' id="item" }
                                    <option value="{$item.id}">{$item.name}</option>
                                    {/volist}
                                </select>
                            </td>
                            <td class="label">单号</td>
                            <td ><input type="text" required name="send_no" id="send_no"/> <div onclick="send()" class="btn btn_primary btn_mini margin15-c">发货</div></td>
                            <td class="label">平台推荐快递</td>
                            <td><a href="http://www.kuaidi100.com/" target="_blank" class="btn btn_mini btn_primary">快递100</a></td>
                        </tr>
                        {else}
                        <tr>
                            <td colspan="8" style="color: #953b39">状态:{$model.send_status}</td>
                        </tr>
                        <tr>
                            <td class="label">快递/物流名称</td>
                            <td width="150px">{$model.send_type}</td>
                            <td class="label">单号</td>
                            <td width="150px">{$model.send_no}</td>
                            <td class="label">快递状态</td>
                            <td>{$model.send_status}</td>
                            <td class="label">平台推荐快递</td>
                            <td><a href="http://www.kuaidi100.com/" target="_blank" class="btn btn_mini btn_primary">快递100</a></td>
                        </tr>
                        {/if}



                    </table>
                </div>
            </div>

            <!--<div class="fieldset">-->
                <!--<h3 class="title">订单处理</h3>-->
                <!--<div class="box">-->
                    <!--<button class="btn btn_primary">快递100</button>-->
                    <!--<button class="btn btn_primary">快递100</button>-->
                    <!--<button class="btn btn_primary">快递100</button>-->
                <!--</div>-->
            <!--</div>-->
        </div>
    </div>
</div>
<script>

    function send() {
        var send_no = $("#send_no").val(),
            send_type_id = $("#send_type_id").val(),
            send_type = $("#send_type_id option:selected").text();

        if(!send_no||!send_type_id||!send_type){
            layer.msg('物流信息请填写')
        }
        $.post('/order/update?id='+{$model.id},{send_no:send_no,send_type_id:send_type_id,send_type:send_type,status:2,send_status:2},function(res){
            console.log(res)
            if(res.code ==1){
                layer.msg('发货成功')
                location.reload()
            }
        })

    }




    function taggleSatus(id,status) {
        var action = 'up';

        if(status==0){
            action = 'down'
        }
        $.post('/mall/'+action,{id:id},function(res){
            if(res.code==1){
                layer.msg('切换成功');
                grid.draw();

            }
        })
    }

</script>